package com.briup.jz.web.controller;

import com.briup.jz.bean.AccountEmployee;
import com.briup.jz.service.IAccountEmployeeService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/accountemployee")
@Api(description="员工账户明细信息")
public class IAccountEmployeeController {

    @Autowired
    private IAccountEmployeeService iAccountEmployeeService;
    @ApiOperation("新建员工账户明细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "transferMoney" ,value = "金额", paramType = "form"),
            @ApiImplicitParam(name = "description" ,value = "描述", paramType = "form"),
            @ApiImplicitParam(name = "type" ,value = "种类", paramType = "form"),
            @ApiImplicitParam(name = "status" ,value = "状态", paramType = "form"),
            @ApiImplicitParam(name = "userId" ,value = "用户id", paramType = "form"),
    })
    @PostMapping("/saveorupdate")
    public Message saveOrUpdate(AccountEmployee accountEmployee){
        iAccountEmployeeService.saveOrUpdate(accountEmployee);
        return MessageUtil.success("操作成功");
    }

    @GetMapping("/delete")
    public Message delete(Long id){
        iAccountEmployeeService.delete(id);
        return MessageUtil.success("删除成功");
    }


    @GetMapping("/query")
    @ApiImplicitParam(name = "id",value = "员工id",paramType = "query")
    public Message query(Long id){
      List<AccountEmployee> employees= iAccountEmployeeService.query(id);
      return  MessageUtil.success(employees);
    }
}
